//------------------------------------------------------------------------------
#ifndef CLIENTCONNECTION_H
#define CLIENTCONNECTION_H
//------------------------------------------------------------------------------
#include "stnmessage.h"

#include <QLocalSocket>
//------------------------------------------------------------------------------
/*!
 * Size of data buffer used for reading
 */
#define DATA_READ_BUFFER_SIZE		1024
//------------------------------------------------------------------------------
/*!
 * Manages a client connection
 */
class ClientConnection : public QObject {
	Q_OBJECT
//------------------------------------------------------------------------------
	public:
		/*!
		 * Communication with a QLocalSocket accepted by the server
		 * @param socket Incoming connection (destroyed by local server)
		 */
		ClientConnection(QLocalSocket *socket, QObject *parent = 0);

		/*!
		 * Destructor
		 */
		~ClientConnection();
//------------------------------------------------------------------------------
	private slots:
		/*!
		 * Data ready to be read on the socket
		 */
		void dataReadyToRead();
//------------------------------------------------------------------------------
	public slots:
		void close();
//------------------------------------------------------------------------------
	signals:
		void disconnected();
		void messageReceived(STNMessage m);
//------------------------------------------------------------------------------
	private:
		QLocalSocket *m_socket;
//------------------------------------------------------------------------------
};
//------------------------------------------------------------------------------
#endif // CLIENTCONNECTION_H
//------------------------------------------------------------------------------
